﻿<template>
    <div class="container myStudent" style="width:99%;margin-top:-25px;">
        <!-- 查询条件 -->
        <div class="query-box query-boxstudent">
            <el-form :model="queryBox" status-icon ref="queryBox">
                <el-row>
                    <el-col :span="4">
                        <div class="depart-box">
                            <div class="slect-title">客户类型</div>
                            <el-select clearable filterable v-model="queryBox.type">
                                <el-option
                                    v-for="item in student_type_options"
                                    :key="item.lable"
                                    :label="item.value"
                                    :value="item.key"
                                ></el-option>
                            </el-select>
                        </div>
                    </el-col>
                    <el-col :span="4">
                        <div class="depart-box">
                            <div class="slect-title">客户来源</div>
                            <el-cascader
                                clearable
                                filterable
                                :key="is_cascader"
                                v-model="queryBox.dataFrom2"
                                :props="addressProps"
                                :options="resources_Options2"
                                placeholder="客户来源"
                            ></el-cascader>
                        </div>
                    </el-col>
                    <el-col :span="4">
                        <el-form-item label prop="code">
                            <el-input v-model="queryBox.parentName" placeholder="联系人">
                                <template slot="prepend">联系人</template>
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">
                        <div class="depart-box">
                            <div class="slect-title">客户进展</div>
                            <el-form-item @change="student_progress_change">
                                <el-select
                                    clearable
                                    filterable
                                    v-model="queryBox.progress"
                                    placeholder="请选择"
                                >
                                    <el-option
                                        v-for="item in student_progress_options"
                                        :key="item.value"
                                        :label="item.value"
                                        :value="item.key"
                                    >{{item.value}}</el-option>
                                </el-select>
                            </el-form-item>
                        </div>
                    </el-col>
                    <el-col :span="4">
                        <el-form-item label prop="code">
                            <el-input v-model="queryBox.code" placeholder="客户编号">
                                <template slot="prepend">客户编号</template>
                            </el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="4">
                        <el-form-item label prop="name">
                            <el-input v-model="queryBox.name" placeholder="学生名称">
                                <template slot="prepend">学生名称</template>
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">
                        <el-form-item label prop="phone">
                            <el-input v-model="queryBox.phone" placeholder="请输入联系电话">
                                <template slot="prepend">联系电话</template>
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">
                        <el-form-item label prop="school">
                            <el-input v-model="queryBox.school" placeholder="学校名称">
                                <template slot="prepend">学校名称</template>
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">
                        <div class="depart-box">
                            <el-form-item label prop="isTodayTracking">
                                <div class="depart-box">
                                    <div class="slect-title">就读年级</div>
                                    <el-select
                                        v-model="queryBox.grade"
                                        placeholder="请选择"
                                        :change="gradeChange"
                                        clearable
                                    >
                                        <el-option
                                            v-for="item in grade_cache_gradeOptions"
                                            :key="item.value"
                                            :label="item.fGradeName"
                                            :value="item.fId"
                                        ></el-option>
                                    </el-select>
                                </div>
                            </el-form-item>
                        </div>
                    </el-col>
                    <el-col :span="4">
                        <div class="depart-box">
                            <el-form-item label prop="isTodayTracking">
                                <div class="depart-box">
                                    <div class="slect-title">紧急回访客户</div>
                                    <el-select
                                        clearable
                                        v-model="queryBox.isCheckRecycleDate"
                                        filterable
                                    >
                                        <el-option
                                            v-for="item in isTodayTracking_options"
                                            :key="item.lable"
                                            :label="item.value"
                                            :value="item.label"
                                        ></el-option>
                                    </el-select>
                                </div>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="11">
                        <div class="depart-box">
                            <div class="slect-title">创建时间</div>
                            <el-date-picker
                                v-model="createDate"
                                type="daterange"
                                :start-placeholder="'开始时间'"
                                :end-placeholder="'结束时间'"
                                range-separator="至"
                                :default-time="['00:00:00', '23:59:59']"
                                value-format="yyyy-MM-dd HH:mm:ss"
                                format="yyyy-MM-dd HH:mm:ss"
                            ></el-date-picker>
                        </div>
                    </el-col>
                    <el-col :span="11" style="margin-left:4.7%">
                        <el-row class="area">
                            <el-col :span="6" style="margin-left:0">
                                <span class="city-title">所在地区：</span>
                            </el-col>
                            <el-col :span="17" style="margin-left:-1px;width:75%">
                                <el-form-item label prop="area">
                                    <el-cascader
                                        clearable
                                        size="large"
                                        :options="options"
                                        v-model="selectedOptions"
                                    ></el-cascader>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-col>
                </el-row>
                <el-row style="margin-top:10px">
                    <el-col :span="4">
                        <div class="depart-box">
                            <div class="slect-title">科目</div>
                            <el-select filterable clearable v-model="queryBox.subject">
                                <el-option
                                    v-for="item in subject_Options"
                                    :key="item.fId"
                                    :label="item.fSpecialtyName"
                                    :value="item.fId"
                                ></el-option>
                            </el-select>
                        </div>
                    </el-col>
                    <el-col :span="4">
                        <div class="depart-box">
                            <div class="slect-title">获取方式</div>
                            <el-select
                                clearable
                                v-model="queryBox.dataFromType"
                                filterable
                                @change="student_parent_type_change"
                            >
                                <el-option
                                    v-for="item in student_data_from_type_options"
                                    :key="item.value"
                                    :label="item.value"
                                    :value="item.key"
                                ></el-option>
                            </el-select>
                        </div>
                    </el-col>
                    <el-col :span="4">
                        <el-form-item label prop="code">
                            <el-input
                                type="number"
                                v-model="queryBox.trackingNum"
                                placeholder="跟进次数"
                            >
                                <template slot="prepend">跟进次数</template>
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <div class="depart-box">
                            <div class="slect-title">最新分配时间</div>
                            <el-date-picker
                                v-model="assignDate"
                                type="daterange"
                                range-separator="至"
                                start-placeholder="开始日期"
                                end-placeholder="结束日期"
                                :default-time="['00:00:00', '23:59:59']"
                                value-format="yyyy-MM-dd HH:mm:ss"
                                format="yyyy-MM-dd HH:mm:ss"
                            ></el-date-picker>
                        </div>
                    </el-col>
                </el-row>
                <el-row>
                    <!-- <el-col :span="4">
            <div class="depart-box">
              <div class="slect-title">是否TMK</div>
              <el-select filterable clearable v-model="queryBox.isTmkContacted">
                <el-option
                  v-for="item in tmk_option"
                  :key="item.key"
                  :label="item.value"
                  :value="item.key"
                ></el-option>
              </el-select>
            </div>
           
                    </el-col>-->
                    <el-col :span="4">
                        <el-form-item label prop="code">
                            <el-input v-model="queryBox.keyWords" placeholder="分主题">
                                <template slot="prepend">分主题</template>
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <!-- 如果是data写死的三级部门就展示这个筛选 -->
                    <el-col :span="4" v-if="isThreeDie">
                        <el-form-item label>
                            <el-input v-model="queryBox.providerClass" placeholder="班级">
                                <template slot="prepend">班级</template>
                            </el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <div class="from-btns">
                <kt-button
                    :label="$t('action.reset')"
                    perms="true"
                    type="primary"
                    @click="reset('queryBox')"
                />
                <kt-button
                    :label="$t('action.search')"
                    perms="true"
                    type="primary"
                    @click="search"
                />
            </div>
        </div>
        <!-- 批量删除按钮 -->
        <div class="add-btns fl">
            <!-- <kt-button :label="$t('action.batchdistribution')" :disabled="this.selections.length===0" 
    perms="customer:student:batchdistribution" type="primary" @click="handlebatchdistribution"/>
    <kt-button :label="$t('action.batchdsubcenter')" :disabled="this.selections.length===0"  
            perms="customer:student:batchcenter" @click="handleCustomerOwnership" type="primary" />-->
            <kt-button
                label="移入客户公海"
                perms="mycustomer:student:delete"
                :size="size"
                type="danger"
                @click="handleBatchDelete"
                :disabled="this.selections.length===0"
                style="float:left;"
            />
        </div>
        <div class="fr">
            <kt-button
                :label="$t('action.download-tmpl')"
                type="primary"
                perms="mycustomer:student:download"
                @click="downloadTmpl"
            ></kt-button>
            <kt-button
                :label="$t('action.batchimport')"
                type="primary"
                perms="mycustomer:student:batchimport"
                @click="customerManagerImport"
            ></kt-button>
            <kt-button
                :label="$t('action.add-user')"
                type="primary"
                perms="mycustomer:student:add"
                @click="handleNewADD"
            ></kt-button>
            <kt-button
                label="索要资源"
                perms="mycustomer:student:askingfor"
                type="primary"
                @click="openAsking"
            ></kt-button>
        </div>
        <!--表格内容栏-->
        <div class="btn">
            <Crm-table
                @selectionChange="selectionChange"
                class="table-width"
                Mycustomerstudent
                width="400"
                permsEdit="mycustomer:student:edit"
                permsSee="mycustomer:student:see"
                permsOutbound="mycustomer:student:outbound"
                permsPresentation="mycustomer:student:presentation"
                permsFollow="mycustomer:student:follow"
                permsExchangeStu="mycustomer:student:exchangeStu"
                :data="pageResult"
                :columns="columns"
                :loading="loading"
                @findPage="findPage"
                @handleFollow="handleFollow"
                @handleEdit="handleEdit"
                @handleSee="handleSee"
                @handleoutbound="handleoutbound"
                @handleOrder="handleOrder"
            ></Crm-table>
        </div>
        <!-- 索要 -->
        <Askingfor
            @colsePop="colsePop"
            @openAsking="openAsking"
            :askingforShow="askingforShow"
            :askingloading="askingloading"
            @submitAsking="submitAsking"
        ></Askingfor>
        <!--导入-->
        <el-dialog
            :title="'批量导入'"
            width="30%"
            :visible.sync="uploadOem"
            :close-on-click-modal="false"
        >
            <el-form :model="form">
                <el-form-item>
                    <el-upload
                        ref="uploadExcel"
                        :action="uploadUrl"
                        :limit="limitNum"
                        :auto-upload="false"
                        accept=".xls"
                        :before-upload="beforeUploadFile"
                        :on-change="fileChange"
                        :on-exceed="exceedFile"
                        :on-success="handleSuccess"
                        :on-error="handleError"
                        :file-list="fileList"
                        :on-remove="handleRemove"
                    >
                        <el-button size="small" plain>选择文件上传</el-button>
                        <div slot="tip" class="el-upload__tip">只能上传xls(Excel97-2004)文件</div>
                    </el-upload>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button :size="size" @click.native="uploadOem = false">{{$t('action.cancel')}}</el-button>
                <el-button :size="size" type="primary" @click.native="uploadFile">{{$t('立即上传')}}</el-button>
            </div>
        </el-dialog>
        <!-- 客户跟进 -->
        <el-dialog
            :title="saveData.name"
            width="90%"
            :visible.sync="addFollow"
            :close-on-click-modal="false"
            @close="closeTrackingPop"
        >
            <div class="second-contain-box stu-pop ma">
                <el-row>
                    <el-col :span="12">
                        <el-col :span="5">
                            <span style="font-size:15px;">电话：</span>
                        </el-col>
                        <el-col :span="5">
                            <span style="margin-left:20px">{{saveData.phone}}</span>
                        </el-col>
                        <el-col :span="8">
                            <span style="margin-left:20px">{{saveData.phoneAdress}}</span>
                        </el-col>
                        <el-col :span="5">
                            <el-button
                                style="margin-left:20px"
                                type="primary"
                                size="mini"
                                @click="handleoutbound2"
                            >外呼</el-button>
                        </el-col>
                    </el-col>
                    <el-col :span="12">
                        <el-col :span="5">
                            <span style="font-size:15px;">备用电话：</span>
                        </el-col>
                        <el-col :span="6">
                            <el-col style="margin-top:-8px">
                                <el-input
                                    :disabled="isSpareChange"
                                    v-model="saveData.sparePhone"
                                    type="number"
                                ></el-input>
                                <!-- <span v-if="isSpareChange">{{saveData.sparePhoneStr}}</span> -->
                                <!-- <span style="margin-left:20px">{{saveData.sparePhone}}</span> -->
                            </el-col>
                        </el-col>
                        <el-col :span="7">
                            <span style="margin-left:20px">{{saveData.sparePhoneAdress}}</span>
                        </el-col>
                        <el-col :span="5" style="margin-top:-3px">
                            <el-button
                                style="margin-left:20px"
                                type="primary"
                                size="mini"
                                @click="handleoutbound3"
                                v-if="saveData.sparePhone"
                            >外呼</el-button>
                        </el-col>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-col :span="6">
                            <span>地区：</span>
                        </el-col>
                        <el-col :span="18">
                            <span>{{saveData.diqu}}</span>
                        </el-col>
                    </el-col>
                    <el-col :span="12">
                        <el-col :span="6">
                            <span>OEM卡类型：</span>
                        </el-col>
                        <el-col :span="18">
                            <span>{{saveData.oemType}}</span>
                        </el-col>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-col :span="6">
                            <span>详细地址：</span>
                        </el-col>
                        <el-col :span="18">
                            <span>{{saveData.areaInput}}</span>
                        </el-col>
                    </el-col>
                </el-row>
                <!-- <el-row>
          
          <el-col :span="12">
            <el-col :span="6">
              <span style="font-size:15px;">年级：</span>
            </el-col>
            <el-col :span="18">
                <el-select
                    v-model="saveData.grade"
                    placeholder="请选择"
                    @change="gradeChange2"
                    clearable
                  >
                    <el-option
                      v-for="item in grade_cache_gradeOptions"
                      :key="item.value"
                      :label="item.fGradeName"
                      :value="item.fId"
                    ></el-option>
                  </el-select>
            </el-col>
          </el-col>
                </el-row>-->
                <el-row>
                    <el-col :span="12">
                        <el-col :span="6">
                            <span>页面地址：</span>
                        </el-col>
                        <el-col :span="18">
                            <span>{{saveData.pageAddress}}</span>
                        </el-col>
                    </el-col>
                    <el-col :span="12">
                        <el-col :span="6">
                            <span style="font-size:15px;">分主题：</span>
                        </el-col>
                        <el-col :span="18">
                            {{saveData.keyWords}}
                            <a
                                v-if="saveData.keyWordsLink"
                                :href="saveData.keyWordsLink"
                                target="_blank"
                                style="margin-left:10px"
                            >查看详情</a>
                            <!-- <span>{{saveData.keyWords}}</span> -->
                        </el-col>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col v-if="!hideSome" :span="12">
                        <el-col :span="6">
                            <span>导入部门：</span>
                        </el-col>
                        <el-col :span="18">
                            <span>{{saveData.importDepartment}}</span>
                        </el-col>
                    </el-col>
                    <el-col :span="12">
                        <el-col :span="6">
                            <span style="font-size:15px;">推广来源：</span>
                        </el-col>
                        <el-col :span="18">
                            <span>{{saveData.source}}</span>
                        </el-col>
                    </el-col>
                </el-row>
                <el-row style="margin:5px 0 !important;">
                    <el-col :span="12">
                        <el-col :span="6">
                            <span style="font-size:15px;">报告类型：</span>
                        </el-col>
                        <el-col :span="18">
                            <span>{{saveData.reportType2}}</span>
                        </el-col>
                    </el-col>
                    <el-col :span="12">
                        <el-col :span="6">
                            <span style="font-size:15px;">报告结果：</span>
                        </el-col>
                        <el-col :span="9">
                            <span>{{saveData.reportResult}}</span>
                            <span style="text-align:left" v-if="!saveData.reportResult">暂无学习记录</span>
                        </el-col>
                        <el-col :span="9">
                            <a
                                class="reportBtn"
                                v-if="saveData.reportResult"
                                :href="baseUrl+'/studentInfo/toStudentReportPage?phone='+this.saveData.phone+'&reportType='+this.saveData.reportType"
                                target="blank"
                            >查看</a>
                        </el-col>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-col :span="6">
                            <span style="font-size:15px;">学习行为查看：</span>
                        </el-col>
                        <el-col :span="9">
                            <span v-if="!isHaveBehavior" style="font-size:15px;color:red">本自然月无学习行为</span>
                            <kt-button
                                v-if="isHaveBehavior"
                                class="stu-btn"
                                label="学习行为"
                                perms="true"
                                type="primary"
                                size="medium"
                                :loading="editLoading"
                                @click="studyBehavior"
                            />
                        </el-col>
                    </el-col>
                    <el-col :span="12">
                        <el-col :span="6">
                            <span style="font-size:15px;">学生行为查看：</span>
                        </el-col>
                        <el-col :span="9">
                            <span
                                v-if="queryLogStateLoadingStr"
                                style="font-size:15px;color:red"
                            >无学生行为数据</span>
                            <kt-button
                                class="stu-btn"
                                v-if="!queryLogStateLoadingStr"
                                label="用户行为查看"
                                perms="true"
                                type="primary"
                                size="medium"
                                :loading="queryLogStateLoading"
                                @click="studyBehavior2"
                            />
                            <kt-button
                                class="stu-btn"
                                label="全部订单"
                                perms="true"
                                type="primary"
                                size="medium"
                                v-if="haveOrder"
                                @click="clickQueryOrderBtn"
                            />
                            <span
                                style="margin-left:10px;font-size:15px;color:red"
                                v-if="!haveOrder"
                            >无订单数据</span>
                        </el-col>
                    </el-col>
                </el-row>
                <el-row style="margin-top:5px !important;">
                    <el-col :span="12">
                        <el-col :span="6">
                            <span style="font-size:15px;">跟进次数：</span>
                        </el-col>
                        <el-col :span="18">
                            <span>{{saveData.trackingNum}}</span>
                        </el-col>
                    </el-col>
                    <el-col :span="12">
                        <el-col :span="6">
                            <i style="margin-top:0">跟进时间：</i>
                        </el-col>
                        <el-col :span="18">
                            <span>{{saveData.contractDate}}</span>
                        </el-col>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-col :span="6">
                            <i>学生姓名：</i>
                        </el-col>
                        <el-col :span="16">
                            <el-input placeholder="请输入内容" v-model="saveData.contactPeople"></el-input>
                        </el-col>
                    </el-col>
                    <el-col :span="12">
                        <el-col :span="6">
                            <span style="font-size:15px;margin-top:15px;display: inline-block;">年级：</span>
                        </el-col>
                        <el-col :span="18">
                            <!-- <span>{{saveData.grade}}</span> -->
                            <el-select
                                v-model="saveData.grade"
                                placeholder="请选择"
                                @change="gradeChange2"
                                clearable
                            >
                                <el-option
                                    v-for="item in grade_cache_gradeOptions"
                                    :key="item.value"
                                    :label="item.fGradeName"
                                    :value="item.fId"
                                ></el-option>
                            </el-select>
                        </el-col>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-col :span="6">
                            <i>客户类型：</i>
                        </el-col>
                        <el-col :span="16">
                            <el-select
                                style="width:100%"
                                :disabled="typeDisabled"
                                v-model="saveData.customerType"
                                placeholder="请选择"
                                clearable
                                @change="typeChange"
                            >
                                <el-option
                                    v-for="item in student_tracktype_options"
                                    :key="item.key"
                                    :label="item.value"
                                    :value="item.key"
                                ></el-option>
                            </el-select>
                        </el-col>
                    </el-col>
                    <el-col :span="12">
                        <el-col :span="6">
                            <i>客户进展：</i>
                        </el-col>
                        <el-col :span="18">
                            <el-select
                                style="width:100%"
                                :disabled="selectDisabled"
                                v-model="saveData.customerProgress"
                                placeholder="请选择"
                                @change="progressChange"
                                clearable
                            >
                                <el-option
                                    v-for="item in student_progress_options2"
                                    :key="item.value"
                                    :label="item.value"
                                    :value="item.key"
                                ></el-option>
                            </el-select>
                        </el-col>
                    </el-col>
                </el-row>
                <el-row v-if="saveData.customerProgress==8">
                    <el-col :span="12">
                        <el-col :span="6">
                            <i>支付方式：</i>
                        </el-col>
                        <el-col :span="16">
                            <el-select
                                style="width:100%"
                                v-model="saveData.payType"
                                placeholder="请选择"
                                clearable
                            >
                                <el-option
                                    v-for="item in payType_options"
                                    :key="item.value"
                                    :label="item.value"
                                    :value="item.key"
                                ></el-option>
                            </el-select>
                        </el-col>
                    </el-col>
                    <el-col :span="12">
                        <el-col :span="6">
                            <i>支付单号：</i>
                        </el-col>
                        <el-col :span="18">
                            <el-input placeholder="请输入内容" v-model="saveData.payNum"></el-input>
                        </el-col>
                    </el-col>
                </el-row>
                <el-row v-if="saveData.customerProgress==8">
                    <el-col :span="3">
                        <i>发票信息 ：</i>
                    </el-col>
                    <el-col :span="21">
                        <el-input placeholder="请输入内容" v-model="saveData.invoice"></el-input>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-col :span="6">
                            <i>沟通结果：</i>
                        </el-col>
                        <el-col :span="16">
                            <el-select
                                style="width:100%"
                                :disabled="typeDisabled"
                                v-model="saveData.contractResult"
                                placeholder="请选择"
                                clearable
                                @change="contractResultChange"
                            >
                                <el-option
                                    v-for="item in student_result_options"
                                    :key="item.value"
                                    :label="item.value"
                                    :value="item.key"
                                ></el-option>
                            </el-select>
                        </el-col>
                    </el-col>
                    <el-col :span="12">
                        <el-col :span="6">
                            <i>沟通形式：</i>
                        </el-col>
                        <el-col :span="18">
                            <el-select
                                style="width:100%"
                                v-model="saveData.contractType"
                                clearable
                                placeholder="请选择"
                            >
                                <el-option
                                    v-for="item in student_communication_type"
                                    :key="item.value"
                                    :label="item.value"
                                    :value="item.key"
                                ></el-option>
                            </el-select>
                        </el-col>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="24">
                        <el-col :span="3">
                            <i>沟通内容：</i>
                        </el-col>
                        <el-col :span="21">
                            <el-input
                                style="width:100%"
                                type="textarea"
                                :rows="2"
                                placeholder="请输入内容"
                                v-model="saveData.contractContent"
                            ></el-input>
                            <span
                                style="color:red;font-size:10px;display:inline-block;margin-top:10px;"
                            >温馨提示：请不要使用不文明词语</span>
                        </el-col>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-col :span="6">
                            <i style="margin-top:5px">跟进人：</i>
                        </el-col>
                        <el-col :span="18" style="margin-top:10px;">{{trackingPeople}}</el-col>
                    </el-col>
                    <el-col :span="12">
                        <el-col :span="6">
                            <i>下次跟进日期：</i>
                        </el-col>
                        <el-col :span="18">
                            <el-date-picker
                                style="width:100%"
                                v-model="saveData.nextContractDate"
                                type="datetime"
                                placeholder="选择日期时间"
                                :default-time="mytime"
                                value-format="yyyy-MM-dd HH:mm:ss"
                                format="yyyy-MM-dd HH:mm:ss"
                                :picker-options="pickerOptions"
                            ></el-date-picker>
                        </el-col>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="24">
                        <el-col :span="3">
                            <span style="font-size:15px;">备注：</span>
                        </el-col>
                        <el-col :span="21">
                            <span>{{comment}}</span>
                        </el-col>
                    </el-col>
                </el-row>
            </div>
            <kt-button
                class="stu-btn"
                :label="$t('action.save')"
                perms="true"
                type="primary"
                size="medium"
                :loading="editLoading"
                @click="updateField()"
            />
            <p class="tracking-tit">跟进情况</p>
            <Crm-table
                :showBatchDelete="showBatchDelete"
                class="tracking-table"
                :data="stuqueryTrackingData"
                :columns="columns2"
                :showOverflowTooltip='false'
                @findPage2="findPage2"
                :loading="loading"
            ></Crm-table>
        </el-dialog>
        <!-- 订单详情 -->
        <el-dialog
            title="订单详情"
            width="70%"
            class="orderListPop"
            :visible.sync="allOrderShow"
            :close-on-click-modal="false"
        >
            <ul v-for="item in orderList">
                <li>
                    {{item.order}}
                    <a
                        :href="item.orderLink"
                        v-if="item.orderLink"
                        target="_blank"
                    >查看详情</a>
                </li>
            </ul>
        </el-dialog>
        <!-- 行为抽屉 -->
        <el-drawer
            class="studentDrawer"
            :visible.sync="drawer"
            size="50%"
            direction="btt"
            :before-close="drawerClose"
            :with-header="false"
        >
            <span
                style="display:inline-block;margin:20px 0;font-weight:bold"
            >{{studyAction?'用户行为统计':'学生学习行为统计'}}</span>
            <div
                class="infinite-list-wrapper"
                style="overflow:auto;height:100%"
                v-loading="drawerLoading"
                element-loading-text="拼命加载中"
            >
                <ul class="list" v-if="!studyAction" infinite-scroll-disabled="disabled">
                    <li v-for="item in studyLogData" class="list-item">
                        <span
                            style="font-weight:bold;color:red"
                        >{{ item.studyLogType?item.studyLogType+'了':item.createTime+" "+item.activityTypeLabel+'--' }}</span>
                        {{item.content}}
                    </li>
                </ul>
                <ul class="list" v-if="studyAction" infinite-scroll-disabled="disabled">
                    <li v-for="item in studyLogData2" class="list-item">
                        <span style="font-weight:bold;color:red">{{item.doTypeStr}}</span>
                        {{item.doSomething}}
                        <a
                            :href="item.linkUrl"
                            v-if="item.linkUrl"
                            target="blank"
                        >{{item.doSomethingStr.indexOf('】')==-1?'查看详情':'查看详情】'}}</a>
                    </li>
                </ul>
                <!-- <kt-button
        class="stu-btn"
        label="显示两天前数据"
        perms="true"
        type="primary"
        size="medium"
        v-if='loading2dayState'
                @click="loading2dayData"></kt-button>-->
                <!-- 显示两天前数据下一页 -->
                <kt-button
                    class="stu-btn"
                    label="点击加载下一页"
                    perms="true"
                    type="primary"
                    size="medium"
                    v-if="loading2dayStateTOnext"
                    :loading="drawerLoading"
                    @click="loading2dayDataToNext(pageRequest3.pageNum)"
                ></kt-button>

                <kt-button
                    class="stu-btn"
                    label="加载30天前的数据"
                    perms="true"
                    type="primary"
                    size="medium"
                    v-if="loading30dayState"
                    :loading="drawerLoading"
                    @click="loading30dayData"
                ></kt-button>
                <kt-button
                    class="stu-btn"
                    label="点击加载下一页"
                    perms="true"
                    type="primary"
                    size="medium"
                    v-if="toNext"
                    :loading="drawerLoading"
                    @click="studentActionLoad2(pageRequest3.pageNum)"
                ></kt-button>
            </div>
        </el-drawer>
    </div>
</template>
<script>
import PopupTreeInput from "@/components/PopupTreeInput";
import KtButton from "@/views/Core/KtButton";
import CrmTable from "@/views/Core/CrmTable";
import CrmSwitch from "@/views/Core/CrmSwitch";
import { CodeToText } from "element-china-area-data";
import { getIFrameUrl } from "@/utils/iframe";
import { baseUrl } from "@/utils/global";
import Cookies from "js-cookie";
import { regionDataPlus } from "element-china-area-data";
import axios from "axios";
import store from "@/store";
import {
    isMobile,
    getPreMonth,
    getPrePreMonth,
    getNextMonth
} from "@/utils/validate";
import { mapActions } from "vuex";
import CrmPermsBox from "@/views/Core/Crmpermsbox";
// 索要
import Askingfor from "@/views/Core/Askingfor";

export default {
    name: "Student",
    components: {
        PopupTreeInput,
        CrmTable,
        KtButton,
        CrmSwitch,
        CrmPermsBox,
        Askingfor
    },
    data() {
        return {
            addressArr: [], //绑定的数据
            is_cascader: Math.random(), //重新渲染标识key
            addressProps: {
                label: "codeValue",
                value: "codeKey",
                lazy: true, //开启异步加载
                lazyLoad(node, resolve) {
                    const { value, level } = node;
                    axios
                        .get(baseUrl + "/code/queryStudentDataFromByGroupId", {
                            params: { id: node.value }
                        })
                        .then(res => {
                            let response = res.data;

                            if (response.result == 1) {
                                resolve(
                                    response.data.map(item => {
                                        item.label = item.label;
                                        item.value = item.codeKey;
                                        item.leaf = "leaf"; //这个必须加，就是让组件识别是不是最后一级
                                        return item;
                                    })
                                );
                            }
                        });
                }
            },
            addressInit: false, //标记组件第一级数据开始加载没有
            exampleData: "30",
            count: 10,
            aa: true,
            selectDisabled: false, //跟进弹窗客户进展状态
            typeDisabled: false,
            checkedPeson: 0,
            student_import_department: [],
            size: "mini",
            gradeCache: "",
            // filters: {
            //   name: ""
            // },
            // 查询条件
            student_data_from_options: [
                {
                    label: " ",
                    key: " "
                }
            ],
            mytime: "",
            showBatchDelete: false,
            // 客户跟进数据
            stuqueryTrackingData: {
                content: []
            },
            pageRequest3: {
                pageNum: 1,
                pageSize: 10
            },
            pageRequest2: {
                pageNum: 1,
                pageSize: 10
            },
            studentContractType_options: [],
            student_type_options: [],
            student_progress_options: [
                {
                    label: " ",
                    key: " "
                }
            ],
            isTodayTracking_options: [
                {
                    value: "是",
                    label: "1"
                }
            ],

            student_data_from_type_options: [
                {
                    label: " ",
                    key: " "
                }
            ],
            assignDate: "",
            grade_cache_gradeOptions: [],
            queryBox: {
                name: "",
                dataFrom: "",
                type: "",
                dataFromType: "",
                progress: "",
                code: "",
                phone: "",
                school: "",
                providerTeacher: "",
                providerAgent: "",
                createDate: "",
                moveDate: "",
                belongToPerson: "",
                pageNum: 0,
                pageSize: 0,
                importDepartment: "",
                grade: "",
                isCheckRecycleDate: "",
                dataFrom2:[]
            },
            width: 200,
            columns: [
                { type: "index", label: "序号", minWidth: 50 },
                { prop: "name", label: "学生姓名", minWidth: 100 },
                { prop: "gradeInfo", label: "所在年级", minWidth: 120 },
                { prop: "subject", label: "科目", minWidth: 120 },
                { prop: "phone", label: "联系电话", minWidth: 100 },
                { prop: "laiyuan", label: "客户来源", minWidth: 120 },
                { prop: "diqu", label: "地区", minWidth: 120 },
                {
                    prop: "keyWords",
                    label: "分主题",
                    minWidth: 220
                },
                { prop: "getType", label: "获取方式", minWidth: 80 },
                { prop: "activityCodeStr", label: "活动名称", minWidth: 100 },
                {
                    prop: "createDate",
                    sortable: "true",
                    label: "创建时间",
                    minWidth: 140
                },
                {
                    prop: "assignDate",
                    sortable: "true",
                    label: "最新分配时间",
                    minWidth: 140
                },
                {
                    prop: "trackingDate",
                    sortable: "true",
                    label: "最新跟进时间",
                    minWidth: 140
                },
                { prop: "trackingNum", label: "跟进次数", minWidth: 70 },
                { prop: "getprogress", label: "客户进展", minWidth: 70 },
                {
                    prop: "importDepartment",
                    label: "导入部门",
                    minWidth: 100,
                    id: "customerImportDepartment"
                },
                { prop: "source", label: "推广来源", minWidth: 100 },
                { prop: "areaInput", label: "详细地址", minWidth: 120 },
                { prop: "school", label: "学校名称", minWidth: 120 },
                { prop: "reportType2", label: "报告类型", minWidth: 80 },
                { prop: "reportResult", label: "报告结果", minWidth: 80 },
                { prop: "code", label: "客户编号", minWidth: 200 }
            ],
            columns2: [
                { type: "index", label: "序号", minWidth: 10 },
                { prop: "contractDate", label: "跟进时间", minWidth: 100 },
                { prop: "contactPeople", label: "学生姓名", minWidth: 50 },
                { prop: "trackingPeople", label: "跟进人", minWidth: 50 },
                // { prop: "contractType", label: "沟通形式", minWidth: 50 },
                
                { prop: "customerType", label: "客户类型", minWidth: 80 },
                { prop: "getprogress", label: "客户进展", minWidth: 50 },
                { prop: "contractResult2", label: "沟通结果", minWidth: 50 },
                { prop: "contractContent", label: "沟通内容", minWidth: 220 },
                {
                    prop: "nextContractDate",
                    label: "下次跟进时间",
                    minWidth: 100
                }
            ],
            columns3: [
                { type: "index", label: "序号", minWidth: 50 },
                { prop: "pageUrl", label: "页面URL", minWidth: 120 },
                { prop: "pageUrl", label: "访客数（UV）", minWidth: 120 },
                { prop: "pageUrl", label: "IP数", minWidth: 120 },
                { prop: "pageUrl", label: "浏览量（PV）", minWidth: 120 },
                { prop: "pageUrl", label: "平均访问时长", minWidth: 120 }
            ],

            pageResult: {
                content: []
            },

            isTodayTracking: "",
            student_type_options: [],
            operation: true, // true:新增, false:编辑
            batchdistribution: false, //显示批量分配弹窗
            customerownership: false, //显示客户归属弹窗
            addFollow: false, //显示跟进窗口
            selectionsLength: "",
            deptTreeProps: {
                label: "name",
                children: "children"
            },
            roles: [],
            selections: [], //选中列表集合
            ids: [], //分配ID集合
            ids2: [],
            deptData: [], //部门树
            deptTree: {
                label: "deptName",
                children: "children"
            },
            timer: null,
            deptinputValue: "",
            // 划分方式
            deptmodeoptions: [
                {
                    label: "分配至部门",
                    value: "11"
                },
                {
                    label: "分配至个人",
                    value: "9"
                }
            ],
            deptmodeoptionsValue: "",
            submitID: "",
            deptId: "",
            userID: "", //人员ID
            deptuseroption: [], //部门用户
            deptuseroptionValue: "",
            branchcenter: [], //分中心下拉
            branchcenterValue: "",
            branchcenterValueID: "",
            branchcenterCodeValue: "", //分中心编码
            addstuformData: {},
            student_type_options: [],
            student_tracktype_options: [],
            TQtoken_init: "",
            phone: "",
            demo: browserfly.noConflict(),
            // 呼叫信息
            callDate: "", //呼叫时间
            call: "",
            timeLength: "", //通话时长
            tqCode: "", //通话的TQ号
            isGetThrough: "", //是否接通
            contractPeople: "", //联系人
            seatCode: "", //坐席号
            student: "", //呼叫的学生ID
            callState: "", //挂断方式
            uploadOem: false, //文件上传
            limitNum: 1, //上传最大个数
            form: {
                file: ""
            },
            baseUrl: baseUrl,
            fileList: [],
            uploadUrl: baseUrl + "/file/upload", //文件上传地址
            downloadTmplUrl: baseUrl + "/template/studentImportTemplate.xlsx", //模板下载地址
            stuTableData: {
                studentInfo: {
                    trackingNum: 0
                }
            },
            saveData: {
                customerType: "",
                contractDate: "",
                customerProgress: "",
                contractContent: "",
                nextContractDate: "",
                contactPeople: "",
                contractType: "",
                contractResult: "",
                studentId: this.$route.query.id,
                phoneAdress: "",
                sparePhoneAdress: "",
                sparePhone: "",
                source: "",
                importDepartment: "",
                grade: "",
                oemType: "",
                payType: "",
                payNum: "",
                invoice: ""
            },
            trackingPeople: Cookies.get("realName"),
            student_communication_type: [],
            // 分中心名称
            restaurants: [],
            branchCenterName: "",
            userName: "",
            createDate: "",
            trackingDate: "",
            //   地区
            options: regionDataPlus,
            selectedOptions: [],
            loading: false, // 加载标识
            nextTrackingDate: "", //应跟进时间
            // 限制跟进时间
            pickerOptions: {
                disabledDate(time) {
                    return time.getTime() < Date.now() - 8.64e7; //如果没有后面的-8.64e7就是不可以选择今天的
                }
            },
            date: new Date(),
            student_result_options: [],
            student_progress_options2: [],
            reportType_options: [],
            reportResult_options: [],
            subject_Options: [],
            comment: "",
            student_import_department: [],
            askingforShow: false,
            askingloading: false,
            askingMessage: "",
            isLoadingSuccess: false, //是否索要成功
            roleId: "", //当前登录用户的角色id
            // roleId1: "307922416041209975", //咨询师
            // roleId2: "307922480151146627", //直销三级部门管理
            // roleId3: "307922544034590863", //直销部门管理
            // roleId4: "318843899038940998", //金丰和校区管理
            // roleId5: "318845886098849661", //金丰和班主任管理
            hideSome: false,
            isSpareChange: false,
            checkExchangeShow: false,
            customerCode: "",
            tableData: [],
            tmk_option: [
                {
                    key: "1",
                    value: "是"
                },
                {
                    key: "2",
                    value: "否"
                }
            ],
            oemType_option: [],
            payType_options: [],
            trackingLockPhone: "",
            threeDie: "445955334918648480",
            isThreeDie: false,
            editLoading: false,
            drawer: false,
            studyLogData: [],
            studyLogData2: [],
            isLoadingDone: false,
            noMore: false,
            studyAction: false,
            drawerLoading: true, //学生行为是否加载完成
            isLaodingActionLoadDone: false,
            loading30dayState: true,
            loading2dayState: true,
            loading2dayStateTOnext: true,
            toNext: true,
            isHaveBehavior: false,
            isHaveBehavior2: false,
            drawerLoading2: true,
            queryLogStateLoading: true,
            queryLogStateLoadingStr: false,
            student_system_cache_options: [],
            haveOrder: false,
            allOrderShow: false,
            orderList: {},
            resources_Options: [],
            resources_Options2: [],
            student_data_from_options_son: [],
            resourcesSon_Options: []
        };
    },
    methods: {
        // 搜索
        search() {
            this.queryBox.dataFrom2 = this.queryBox.dataFrom2.toString();
            this.queryBox.dataFrom =this.queryBox.dataFrom2.split(',')[1]
            
            this.loading = true;    
            if (this.createDate != null) {
                this.queryBox.createDateStart = this.createDate[0];
                this.queryBox.createDateEnd = this.createDate[1];
            } else {
                this.queryBox.createDateStart = "";
                this.queryBox.createDateEnd = "";
            }
            if (this.trackingDate != null) {
                this.queryBox.trackingDateStart = this.trackingDate[0];
                this.queryBox.trackingDateEnd = this.trackingDate[1];
            } else {
                this.queryBox.trackingDateStart = "";
                this.queryBox.trackingDateEnd = "";
            }

            this.queryBox.province = this.selectedOptions[0];
            this.queryBox.city = this.selectedOptions[1];
            this.queryBox.area = this.selectedOptions[2];
            if (this.nextTrackingDate != null) {
                this.queryBox.nextTrackingDateStart = this.nextTrackingDate[0];
                this.queryBox.nextTrackingDateEnd = this.nextTrackingDate[1];
            } else {
                this.queryBox.nextTrackingDateStart = "";
                this.queryBox.nextTrackingDateEnd = "";
            }
            if (this.assignDate != null) {
                this.queryBox.assignDateStart = this.assignDate[0];
                this.queryBox.assignDateEnd = this.assignDate[1];
            } else {
                this.queryBox.assignDateStart = "";
                this.queryBox.assignDateEnd = "";
            }

            this.pageRequest.pageNum = 1;
            this.findPage(null);
        },
        // 获取分页数据
        findPage: function(data) {
            if (data !== null) {
                this.loading = true;
                this.pageRequest = data.pageRequest;
            }
            this.queryBox.pageSize = this.pageRequest.pageSize;
            this.queryBox.pageNum = this.pageRequest.pageNum;

            let die = Cookies.get("threeLevelDeptId");
            if (die == this.threeDie) {
                this.isThreeDie = true;
            }
            if (this.queryBox.isCheckRecycleDate == "1") {
                this.pageRequest = Object.assign(
                    {},
                    this.pageRequest,
                    this.queryBox,
                    {
                        type: 1 // 当筛选项选择了紧急回访客户  type传1
                    }
                );
            } else {
                this.pageRequest = Object.assign(
                    {},
                    this.pageRequest,
                    this.queryBox
                );
            }
            this.$api.student
                .todayNeedToTrackByAssginAndUserSetResource(this.pageRequest)
                .then(res => {
                    let content = {
                        content: res.listStudentInfo,
                        totalSize: res.total
                    };
                    this.pageResult = content;
                    this.pageResult.content.forEach(item => {
                        let reg = new RegExp("(\\d{4})(\\d{2})(\\d{5})");
                        item.phoneStr = item.phone.replace(reg, "$1**$3");
                        if (item.province == null || item.province == "null") {
                            item.diqu = "";
                        } else if (
                            (item.province != null && item.city == null) ||
                            (item.province != "null" && item.city == "null")
                        ) {
                            item.diqu = CodeToText[item.province];
                        } else if (
                            (item.province != null &&
                                item.city != null &&
                                item.area == null) ||
                            (item.province != "null" &&
                                item.city != "null" &&
                                item.area == "null")
                        ) {
                            item.diqu =
                                CodeToText[item.province] +
                                CodeToText[item.city];
                        } else if (
                            (item.province != null &&
                                item.city != null &&
                                item.area != null) ||
                            (item.province != "null" &&
                                item.city != "null" &&
                                item.area != "null")
                        ) {
                            item.diqu =
                                CodeToText[item.province] +
                                CodeToText[item.city] +
                                CodeToText[item.area] +
                                (item.areaInput == null ? "" : item.areaInput);
                        }
                        this.student_data_from_options2.forEach(type_item => {
                            if (type_item.key == item.dataFrom) {
                                item.laiyuan = type_item.value;
                            }
                        });
                        this.student_progress_options.forEach(progress_item => {
                            if (progress_item.key == item.progress) {
                                item.getprogress = progress_item.value;
                            }
                        });
                        if (item.isTmkContacted == 1) {
                            item.TMK = "是";
                        } else {
                            item.TMK = "否";
                        }
                        // 获取方式对应
                        this.student_data_from_type_options.forEach(
                            data_from_type_item => {
                                if (
                                    data_from_type_item.key == item.dataFromType
                                ) {
                                    item.getType = data_from_type_item.value;
                                }
                            }
                        );
                        // 客户类型对应
                        this.student_type_options.forEach(student_type_item => {
                            if (student_type_item.key == item.type) {
                                item.type = student_type_item.value;
                                item.customerType = student_type_item.key;
                            }
                        });
                        //年级
                        this.gradeCache.forEach(gradeItem => {
                            if (gradeItem.fId == item.grade) {
                                item.gradeInfo = gradeItem.fGradeName;
                            }
                        });
                        //报告类型转义
                        this.reportType_options.forEach(reportTypeItem => {
                            if (reportTypeItem.key == item.reportType) {
                                item.reportType2 = reportTypeItem.value;
                            }
                        });
                        //报告结果转义
                        this.reportResult_options.forEach(reportResultItem => {
                            if (reportResultItem.key == item.reportResult) {
                                item.reportResult = reportResultItem.value;
                            }
                        });
                        // 学科
                        this.studentSubject.forEach(subItem => {
                            if (subItem.fId == item.subject) {
                                item.subject = subItem.fSpecialtyName;
                            }
                        });
                        // 导入部门转换
                        this.student_import_department.forEach(subItem => {
                            if (subItem.key == item.importDepartment) {
                                item.importDepartment = subItem.value;
                            }
                        });
                        // 转换推广来源
                        this.student_TGsource_options.forEach(TGsourceItem => {
                            if (TGsourceItem.key == item.source) {
                                item.source = TGsourceItem.value;
                            }
                        });
                        //OEM卡类型转换
                        this.oemType_option.forEach(oemItem => {
                            if (oemItem.key == item.oemType) {
                                item.oemType = oemItem.value;
                            }
                        });
                        // 学制转换
                        this.student_system_cache_options.forEach(
                            systemItem => {
                                if (systemItem.fId == item.schoolSystem) {
                                    item.schoolSystemStr =
                                        systemItem.fSystemName;
                                }
                            }
                        );
                        // 判断分主题有没有小额付费
                        if (item.keyWords) {
                            if (
                                item.keyWords.indexOf("http") ||
                                item.keyWords.indexOf("https")
                            ) {
                                let index =
                                    item.keyWords.indexOf("http") ||
                                    item.keyWords.indexOf("https");
                                if (index > -1) {
                                    item.keyWordsType = "1";
                                }
                            }
                        }
                    });
                    this.loading = false;
                })
                .then(data != null ? data.callback : "");
        },
        // 重置
        reset(queryBox) {
            this.$refs.queryBox.resetFields();
            this.queryBox.type = "";
            this.queryBox.dataFrom = "";
            this.queryBox.progress = "";
            this.queryBox.providerAgent = "";
            this.createDate = "";
            this.trackingDate = "";
            this.queryBox.dataFromType = "";
            this.branchCenterName = "";
            this.userName = "";
            this.queryBox.belongTo = "";
            this.queryBox.importDepartment = "";
            this.queryBox.createDateStart = "";
            this.queryBox.createDateEnd = "";
            this.queryBox.trackingDateStart = "";
            this.queryBox.trackingDateEnd = "";
            this.selectedOptions = [];
            this.queryBox.province = "";
            this.queryBox.city = "";
            this.queryBox.parentName = "";
            this.queryBox.area = "";
            this.queryBox.trackingNum = "";
            this.pageRequest.pageNum = 1;
            this.queryBox.grade = "";
            this.nextTrackingDate = "";
            this.queryBox.nextTrackingDateStart = "";
            this.queryBox.nextTrackingDateEnd = "";
            this.queryBox.assignDateStart = "";
            this.queryBox.assignDateEnd = "";
            this.assignDate = "";
            this.queryBox.keyWords = "";
            this.queryBox.subject = "";
            this.queryBox.isCheckRecycleDate = "";
            this.queryBox.isTmkContacted = "";
            this.queryBox.dataFromGroupKey = "";
            this.queryBox.dataFromGroupKeyF = "";
            this.queryBox.dataFrom2 = "";
            this.findPage(null);
        },
        // 批量删除
        handleBatchDelete() {
            this.ids2 = [];
            let idstu2 = this.selections.map(item => item.id);
            // this.dataFormAdd = Object.assign({}, params.row);
            this.ids2 = idstu2;
            this.$confirm(
                "确认删除" + this.selections.length + "个客户吗？",
                "提示",
                {}
            ).then(() => {
                // this.editLoading = true;
                this.$api.student
                    .studentAssignResourceAssign({
                        listStudentId: this.ids2,
                        belongType: 13
                    })
                    .then(res => {
                        if (res.result == 2) {
                            this.$message({
                                message: res.msg,
                                type: "error"
                            });
                        } else {
                            // this.editLoading = false
                            this.findPage(null);
                        }
                    });
            });
        },
        // 查看客户档案
        handleSee: function(params) {
            this.dataForm = Object.assign({}, params.row);
            this.$router.push({
                path: "/Customerfile/Student",
                query: {
                    id: this.dataForm.id
                }
            });
        },
        // 报单跳转
        handleOrder(params) {
            window.open(
                this.global.baseUrl +
                    "/oc/autoLoginOC?page=addOrder&orderPhone=" +
                    params.row.phone +
                    (params.row.name ? "&studentName=" + params.row.name : "") +
                    (params.row.oemAccount
                        ? "&studentNumber" + params.row.oemAccount
                        : "") +
                    (params.row.grade
                        ? "&grade=" +
                          params.row.grade +
                          "&gradeStr=" +
                          params.row.gradeInfo
                        : "") +
                    (params.row.schoolSystem
                        ? "&schoolSystemStr=" +
                          params.row.schoolSystemStr +
                          "&schoolSystem=" +
                          params.row.schoolSystem
                        : "") +
                    (params.row.school ? "&school=" + params.row.school : "")
            );
        },
        // 新增客户
        handleNewADD: function() {
            this.$router.push({
                path: "/Customerfile/AddMyStudent",
                query: {
                    name: "myCustomerAdd"
                }
            });
        },
        // 获取服务器时间
        getServerTime() {
            this.$api.dict.getTime().then(res => {
                this.saveData.contractDate = res.data;
            });
        },
        // 客户跟进
        handleFollow: function(params) {
            let reg = new RegExp("(\\d{4})(\\d{2})(\\d{5})");
            this.getServerTime();
            this.addFollow = true;
            this.trackingLockPhone = params.row.phone;
            this.saveData.phoneStr = params.row.phone.replace(reg, "$1**$3");
            this.trackingLock(this.trackingLockPhone, 1);
            this.saveData.trackingNum = params.row.trackingNum;
            this.saveData.name = params.row.name;
            this.saveData.contactPeople = params.row.name;
            this.saveData.contractType = "1";
            this.saveData.customerType = params.row.customerType;
            if (params.row.progress == "8") {
                this.saveData.customerProgress = "已成单";
            } else if (params.row.progress == "2") {
                this.saveData.customerProgress = "";
            } else if (params.row.progress == "1") {
                this.saveData.customerProgress = "";
            } else if (params.row.progress == "5") {
                this.saveData.customerProgress = "";
            } else if (params.row.progress == "9") {
                this.saveData.customerProgress = "";
            } else {
                this.saveData.customerProgress = params.row.progress;
            }
            this.studentQueryInfo(params.row.id);
            this.saveData.importDepartment = params.row.importDepartment;
            this.saveData.source = params.row.source;
            this.saveData.studentId = params.row.id;
            this.saveData.pageAddress = params.row.pageAddress;
            this.saveData.keyWords = params.row.keyWords;
            this.saveData.phone = params.row.phone;
            // this.saveData.contractDate = this.dateFormat(new Date());
            this.pageRequest2.pageNum = "1";
            this.saveData.reportType2 = params.row.reportType2;
            this.saveData.reportType = params.row.reportType;
            this.saveData.reportResult = params.row.reportResult;
            this.saveData.grade = params.row.grade;
            this.saveData.diqu = params.row.diqu;
            this.saveData.sparePhone = params.row.sparePhone;
            this.saveData.areaInput=params.row.areaInput
            if (params.row.sparePhone) {
                this.saveData.sparePhoneStr = params.row.sparePhone.replace(
                    reg,
                    "$1**$3"
                );
            }

            this.saveData.oemType = params.row.oemType;
            this.old = params.row.grade;
            // this.studentActionLoad3(null,'handleFollow',1)
            this.studentActionLoad(null, "handleFollow");
            this.$api.student
                .queryCallAddress({ phone: params.row.phone })
                .then(res => {
                    let jsonObj = JSON.parse(res.msg);
                    this.saveData.phoneAdress = jsonObj.result.att;
                });
            if (params.row.sparePhone != null) {
                this.$api.student
                    .queryCallAddress({ phone: params.row.sparePhone })
                    .then(res => {
                        let jsonObj = JSON.parse(res.msg);
                        this.saveData.phoneAdress = jsonObj.result.att;
                    });
                this.isSpareChange = true;
            } else {
                this.isSpareChange = false;
            }
            this.get_result();

            this.trackingStuId = params.row.id;
            this.student = params.row.id;
            this.trackingStuPhone = params.row.phone;
            this.trackingSparePhone = params.row.sparePhone;
            this.saveData.keyWords = params.row.keyWords;
            this.queryLogState(params.row.phone);
            // this.wac();
            this.findPage2(null);
            // 转化分主题
            if (this.saveData.keyWords) {
                if (
                    this.saveData.keyWords.indexOf("http") ||
                    this.saveData.keyWords.indexOf("https")
                ) {
                    let index =
                        this.saveData.keyWords.indexOf("http") ||
                        this.saveData.keyWords.indexOf("https");
                    if (index != -1) {
                        this.saveData.keyWordsLink = this.saveData.keyWords.substring(
                            index,
                            this.saveData.keyWords.length
                        );
                        this.saveData.keyWords = this.saveData.keyWords.substring(
                            0,
                            index
                        );
                    } else {
                        this.saveData.keyWordsLink = null;
                    }
                }
            } else {
                this.saveData.keyWordsLink = null;
            }

            // 查询订单
            this.queryOrderBtn(params.row.phone);
        },
        // 查询是否有学习日志
        queryLogState(phone) {
            this.$api.student.queryLogState({ phone: phone }).then(res => {
                if (res.msg == "1") {
                    this.queryLogStateLoading = false;
                    this.queryLogStateLoadingStr = false;
                } else if (res.msg == "2") {
                    this.queryLogStateLoadingStr = true;
                    this.queryLogStateLoading = false;
                }
            });
        },
        // 锁定跟进
        trackingLock: function(phone, lockStatus) {
            // console.log(params)
            this.$api.student
                .trackingLock({
                    phone: phone,
                    lockStatus: lockStatus
                })
                .then(res => {});
        },
        // 更新备用电话
        updateField(params) {
            let phone2 = this.saveData.sparePhone;
            let dataItem = {
                id: this.saveData.studentId,
                sparePhone: this.saveData.sparePhone
            };
            if (!this.isSpareChange) {
                if (phone2 == "" || phone2 == null) {
                    this.handleSave();
                } else {
                    if ((phone2 != undefined) & (phone2 != "")) {
                        if (!isMobile(phone2)) {
                            this.$message({
                                message: "请输入正确的备用手机号！",
                                type: "error"
                            });
                            return false;
                        }
                        this.$api.student.updateField(dataItem).then(res => {
                            if (res.result == 2) {
                                this.$message({
                                    message: res.msg,
                                    type: "error"
                                });
                                return false;
                            }
                            this.handleSave();
                        });
                    }
                }
            } else {
                this.handleSave();
            }
        },
        // 保存跟进数据
        handleSave() {
            this.editLoading = true;
            let phone2 = this.saveData.sparePhone;
            let dataItem = {
                id: this.saveData.studentId,
                sparePhone: this.saveData.sparePhone
            };
            if (this.saveData.customerProgress == 8) {
                if (
                    this.saveData.invoice == "" ||
                    this.saveData.payNum == "" ||
                    this.saveData.payType == ""
                ) {
                    this.$message({
                        message:
                            "请填写成单信息！（支付方式、支付单号、发票信息）",
                        type: "error"
                    });
                    this.editLoading = false;
                    return false;
                } else {
                    this.$api.student
                        .addstudentTracking(this.saveData)
                        .then(res => {
                            if (res.result != 1) {
                                this.$message({
                                    message: res.msg,
                                    type: "error"
                                });
                                this.editLoading = false;
                                return;
                            } else {
                                this.trackingLock(this.trackingLockPhone, 2);
                                this.$message({
                                    message: res.msg,
                                    type: "success"
                                });
                                this.editLoading = false;
                                this.addFollow = false;
                                this.saveData.customerProgress = "";
                                this.saveData.customerType = "";
                                this.saveData.contractContent = "";
                                this.saveData.nextContractDate = "";
                                this.saveData.contractType = "";
                                this.saveData.contactPeople = "";
                                this.saveData.contractResult = "";
                                this.saveData.payType = "";
                                this.saveData.payNum = "";
                                this.saveData.invoice = "";
                                this.comment = "";
                                this.findPage(null);
                            }
                        });
                }
            }
            this.$api.student.addstudentTracking(this.saveData).then(res => {
                if (res.result != 1) {
                    this.$message({
                        message: res.msg,
                        type: "error"
                    });
                    this.editLoading = false;
                    return;
                } else {
                    this.trackingLock(this.trackingLockPhone, 2);
                    this.$message({
                        message: res.msg,
                        type: "success"
                    });
                    this.editLoading = false;
                    this.addFollow = false;
                    this.saveData.customerProgress = "";
                    this.saveData.customerType = "";
                    this.saveData.contractContent = "";
                    this.saveData.nextContractDate = "";
                    this.saveData.contractType = "";
                    this.saveData.contactPeople = "";
                    this.saveData.contractResult = "";
                    this.saveData.payType = "";
                    this.saveData.payNum = "";
                    this.saveData.invoice = "";
                    this.comment = "";
                    this.findPage(null);
                }
            });
        },
        // 查询学生跟进列表
        findPage2(data) {
            if (data !== null) {
                this.loading = true;
                this.pageRequest2 = data.pageRequest;
            }
            this.$api.student
                .queryStudentTrackingList({
                    studentId: this.saveData.studentId,
                    pageSize: this.pageRequest2.pageSize,
                    pageNum: this.pageRequest2.pageNum
                })
                .then(res => {
                    let content = {
                        content: res.listStudentTrackingInfo,
                        totalSize: res.total
                    };

                    this.stuqueryTrackingData = content;
                    this.loading = false;
                    this.stuqueryTrackingData.content.forEach(item => {
                        // 进展转换
                        this.student_progress_options.forEach(progress_item => {
                            if (progress_item.key == item.customerProgress) {
                                item.getprogress = progress_item.value;
                            }
                        });
                        // 类型转换
                        this.student_type_options.forEach(type_item => {
                            if (type_item.key == item.customerType) {
                                item.customerType = type_item.value;
                            }
                        });
                        // 沟通形式转换
                        this.studentContractType_options.forEach(
                            communication_item => {
                                if (
                                    communication_item.key == item.contractType
                                ) {
                                    item.contractType =
                                        communication_item.value;
                                }
                            }
                        );

                        // 沟通结果转换
                        this.student_result_options.forEach(result_item => {
                            if (result_item.key == item.contractResult) {
                                item.contractResult2 = result_item.value;
                            }
                        });
                    });
                })
                .then(data != null ? data.callback : "");
        },
        // 获取客户档案（备注）
        studentQueryInfo(params) {
            this.$api.student
                .studentQueryInfoWithEscape({ id: params })
                .then(res => {
                    if (res.result == 1) {
                        this.comment = res.studentInfoAttr.comment;
                    }
                });
        },
        // 获取选中的表格数据
        selectionChange: function(selections) {
            this.selections = selections.selections;
        },
        // 修改客户档案
        handleEdit: function(params) {
            this.dataForm = Object.assign({}, params.row);
            // console.log(params.row)
            this.$router.push({
                path: "/Customerfile/EditStudent",
                query: {
                    id: this.dataForm.id
                }
            });
        },
        // 菜单树选中
        handleOptionClick() {},
        // 获取来源
        get_student_data_from() {
            this.student_data_from_options2 = JSON.parse(
                localStorage.getItem("studentSource")
            );
            this.payType_options = JSON.parse(
                localStorage.getItem("studentPayType")
            );
            // 获取学制
            this.student_system_cache_options = JSON.parse(
                localStorage.getItem("systemCache")
            );
        },
        // 获取进展
        get_student_progress() {
            this.student_progress_options = JSON.parse(
                localStorage.getItem("studenProgress")
            );
            // this.$api.dropdown.oemType().then(res =>{
            //     this.oemType=res.keyValueList
            // })
            // this.oemType = JSON.parse(localStorage.getItem("oemType"));
        },
        // 获取OEM卡类型
        get_oemType() {
            this.oemType_option = JSON.parse(localStorage.getItem("oemType"));
        },
        student_progress_change(value) {
            this.queryBox.student_progressValue = value.toString();
        },
        get_student_type() {
            this.$api.user
                .optionsList({ codeType: "student_type" })
                .then(res => {
                    this.student_type_options = res.keyValueList;
                });
        },
        // 获取跟进客户类型
        get_student_track_type() {
            this.student_tracktype_options = JSON.parse(
                localStorage.getItem("stdentTpye")
            );
        },
        get_student_data_from_type() {
            this.student_data_from_type_options = JSON.parse(
                localStorage.getItem("stdentDataFromType")
            );
        },
        student_parent_type_change(value) {
            this.info.studentInfoDetail.studentInfoAttr.parentType = value.toString();
        },
        // 获取沟通类型
        get_studentContractType() {
            this.studentContractType_options = JSON.parse(
                localStorage.getItem("studentContractType")
            );
        },
        // 获取年级
        get_grade_cache() {
            this.grade_cache_gradeOptions = JSON.parse(
                localStorage.getItem("gradeCache")
            );
        },
        gradeChange(item) {
            this.queryBox.grade = item.fId;
        },
        gradeChange2(item) {
            this.saveData.grade = item;
            // this.saveData.grade = item.fId;
        },
        // 点击外呼
        handleoutbound(params) {
            this.get_tqToken();
            let studentId = params.row.id;
            this.student = params.row.id;
            this.phone = params.row.phone;
            this.$api.user
                .callOut({
                    op: "makecall",
                    phone: this.phone,
                    uin: Cookies.get("uin"),
                    adminUin: Cookies.get("admin_uin"),
                    token: Cookies.get("tqToken")
                })
                .then(res => {
                    if (res.result == 2) {
                        this.$message({
                            message: res.msg,
                            type: "error"
                        });
                    } else {
                        this.$message({
                            message: "外呼成功！",
                            type: "success"
                        });
                        // this.wac()
                    }
                });
            const makeCallCallBack = function(ret, jsonObject) {
                // console.log(JSON.stringify(ret));
            };
        },

        // 跟进弹窗外呼
        handleoutbound2(params) {
            this.get_tqToken();
            this.student = this.trackingStuId;
            this.$api.user
                .callOut({
                    op: "makecall",
                    phone: this.trackingStuPhone,
                    uin: Cookies.get("uin"),
                    adminUin: Cookies.get("admin_uin"),
                    token: Cookies.get("tqToken")
                })
                .then(res => {
                    if (res.result == 2) {
                        this.$message({
                            message: res.msg,
                            type: "error"
                        });
                    } else {
                        this.$message({
                            message: "外呼成功！",
                            type: "success"
                        });
                        // this.wac();
                    }
                });
            const makeCallCallBack = function(ret, jsonObject) {
                // console.log(JSON.stringify(ret));
            };
        },
        // 跟进窗口外呼备用电话
        handleoutbound3(params) {
            this.get_tqToken();
            this.student = this.trackingStuId;
            if (isMobile(this.trackingSparePhone)) {
                this.$api.user
                    .callOut({
                        op: "makecall",
                        phone: this.trackingSparePhone,
                        uin: Cookies.get("uin"),
                        adminUin: Cookies.get("admin_uin"),
                        token: Cookies.get("tqToken")
                    })
                    .then(res => {
                        if (res.result == 2) {
                            this.$message({
                                message: res.msg,
                                type: "error"
                            });
                        } else {
                            this.$message({
                                message: "外呼成功！",
                                type: "success"
                            });
                            // this.wac();
                        }
                    });
                const makeCallCallBack = function(ret, jsonObject) {
                    // console.log(JSON.stringify(ret));
                };
            } else {
                this.$message({
                    message: "电话号码不正确！",
                    type: "error"
                });
            }
        },

        wac() {
            // 监听通话事件
            this.demo.monitorEvent(
                "callEvent",
                function(message, jsonObject) {
                    // 时间转化
                    function timestampToTime(timestamp) {
                        let date = new Date(timestamp / 1000);
                        var Y = date.getFullYear() + "-";
                        var M =
                            (date.getMonth() + 1 < 10
                                ? "0" + (date.getMonth() + 1)
                                : date.getMonth() + 1) + "-";
                        var D = date.getDate() + " ";
                        var h = date.getHours() + ":";
                        var m = date.getMinutes() + ":";
                        var s = date.getSeconds();
                        return Y + M + D + h + m + s;
                    }
                    let callDate = timestampToTime(
                        message.call_event.create_time
                    );
                    // 通话时长
                    let timeLength = (
                        (message.call_event.hangup_time -
                            message.call_event.answer_time) /
                        1000000
                    ).toFixed(0);
                    if (timeLength >= 10) {
                        this.is_answer = 1;
                        timeLength;
                    } else {
                        this.is_answer = 2;
                        timeLength = 0;
                    }
                    // 提交给服务器
                    if (message.call_event.call_state == "agent_hangup") {
                        if (this.student) {
                            axios
                                .post(baseUrl + "/studentCall/call", {
                                    callDate: callDate, //呼叫时间
                                    timeLength: timeLength, //通话时长
                                    tqCode: Cookies.get("uin"), //通话的TQ号
                                    isGetThrough: this.is_answer, //是否接通1接通  2未接通
                                    seatCode: message.call_event.seat_dbid, //坐席号
                                    studentId: this.student //呼叫的学生ID
                                })
                                .then(res => {
                                    if (res.result == 1) {
                                    }
                                    this.findPage(null);
                                });

                            console.log("挂机");
                        }
                    }
                }.bind(this)
            );
        },
        // 初始化TQ
        get_tqToken() {
            const admin_uin = Cookies.get("admin_uin");
            const uin = Cookies.get("uin");
            const strid = "";
            const appid = Cookies.get("appid");
            const appkey = Cookies.get("appkey");
            const ct = Math.round(new Date().getTime() / 1000).toString();
            const sign2 = hex_md5(appid + "*(**)*" + appkey).toUpperCase();
            const ss =
                admin_uin +
                "&" +
                uin +
                "&" +
                strid +
                "&" +
                appid +
                "&" +
                sign2 +
                "&" +
                ct;
            const sign1 = hex_md5(ss).toUpperCase();
            const sign = sign2.toUpperCase();
            this.demo.init({
                debug: true, // 日志是否输出 default false
                strid: "",
                // uin:Cookies.get('TQnumber') , // 账号 / 用户名 必填
                uin: Cookies.get("uin"),
                admin_uin: Cookies.get("admin_uin"), // 管理员账号
                appid: Cookies.get("appid"), // 唯一凭证
                access_token: Cookies.get("TQtoken_init"),
                // access_token:'645EAECEFF9EA9FF237C2FA430B2A1E3A9151E5C3035266D7701E4922AEA5F7F1B77B7762F7774511607EEA61E707FCA' , // 密文
                server_url: "https://vipedu.tq.cn" //如：http://vip.tq.cn
            });
        },
        // 批量导入
        customerManagerImport: function() {
            this.uploadOem = true;
            if (this.form.file != "") {
                this.$refs.uploadExcel.clearFiles();
                this.form.file = "";
            }
        },
        // 文件超出个数限制时的钩子
        exceedFile(files, fileList) {
            this.$notify.warning({
                title: "警告",
                message: `只能选择 ${
                    this.limitNum
                } 个文件，当前共选择了 ${files.length + fileList.length} 个`
            });
        },
        // 文件状态改变时的钩子
        fileChange(file, fileList) {
            this.form.file = file.raw;
        },
        // 上传文件之前的钩子, 参数为上传的文件,若返回 false 或者返回 Promise 且被 reject，则停止上传
        beforeUploadFile(file) {
            console.log("before upload");
            console.log(file);
            let extension = file.name.substring(file.name.lastIndexOf(".") + 1);
            let size = file.size / 1024 / 1024;
            if (extension !== "xls") {
                this.$notify.warning({
                    title: "警告",
                    message: `只能上传Excel97-2004（即后缀是.xls）的文件`
                });
            }
            1;
        },
        // 文件上传成功时的钩子
        handleSuccess(res, file, fileList) {
            this.$refs.uploadExcel.clearFiles();
            this.form.file = "";
            this.$notify.success({
                title: "成功",
                message: `文件上传成功,数据处理中,稍后在我的消息中查看！`
            });
        },
        // 文件上传失败时的钩子
        handleError(err, file, fileList) {
            this.$notify.error({
                title: "错误",
                message: `文件上传失败`
            });
        },
        uploadFile() {
            let formData = new FormData();
            formData.append("file", this.form.file);
            axios
                .post(this.uploadUrl, formData, {
                    "Content-Type": "multipart/form-data"
                })
                .then(res => {
                    if (res.data.result == 1) {
                        this.handleSuccess();
                        let path = res.data.fileUrl;
                        this.$api.student
                            .studentInfoMyCustomerImport({ path: path })
                            .then(res => {
                                console.log(res);
                                this.uploadOem = false;
                                this.findPage(null);
                            });
                    } else {
                        this.handleError();
                    }
                });
        },
        // 删除上传列表操作
        handleRemove(file, fileList) {
            this.form.file = "";
        },

        // 下载模板
        downloadTmpl() {
            this.getStuTempl();
        },
        // 沟通形式
        get_contractType() {
            this.student_communication_type = JSON.parse(
                localStorage.getItem("studentContractType")
            );
        },
        // 获取时间
        dateFormat: function(time) {
            var date = new Date(time);
            var year = date.getFullYear();
            /* 在日期格式中，月份是从0开始的，因此要加0
             * 使用三元表达式在小于10的前面加0，以达到格式统一  如 09:11:05
             * */
            var month =
                date.getMonth() + 1 < 10
                    ? "0" + (date.getMonth() + 1)
                    : date.getMonth() + 1;
            var day =
                date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
            var hours =
                date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
            var minutes =
                date.getMinutes() < 10
                    ? "0" + date.getMinutes()
                    : date.getMinutes();
            var seconds =
                date.getSeconds() < 10
                    ? "0" + date.getSeconds()
                    : date.getSeconds();
            // 拼接
            return (
                year +
                "-" +
                month +
                "-" +
                day +
                " " +
                hours +
                ":" +
                minutes +
                ":" +
                seconds
            );
        },
        get_dataTime() {
            let dateTime = new Date();
            // this.saveData.contractDate = this.dateFormat(dateTime);
            let mytime = dateTime.toLocaleTimeString("chinese", {
                hour12: false
            }); //获取当前时间
            this.mytime = mytime;
        },

        // 分中心远程搜索
        querySearchAsync(queryString, callback) {
            let restaurants = [{}];
            let results = "";
            this.$api.dropdown.branchcenter().then(res => {
                for (let i of res.branchCenterInfoList) {
                    i.value = i.name; //将想要展示的数据作为value
                }
                restaurants = res.branchCenterInfoList;
                results = queryString
                    ? restaurants.filter(this.createFilter(queryString))
                    : restaurants;
                callback(results);
            });
        },
        createFilter(queryString) {
            return restaurant => {
                return (
                    restaurant.name
                        .toLowerCase()
                        .indexOf(queryString.toLowerCase()) === 0
                );
            };
        },
        handleSelect(item) {
            this.queryBox.providerAgent = item.id;
        },
        // 销售人员远程搜索
        querySearchAsync2(queryString, callback) {
            let restaurants = [{}];
            let results = "";
            this.$api.dropdown.users({ userType: 3 }).then(res => {
                for (let i of res.userInfoList) {
                    i.value = i.realName; //将想要展示的数据作为value
                }
                restaurants = res.userInfoList;
                results = queryString
                    ? restaurants.filter(this.createFilter2(queryString))
                    : restaurants;
                callback(results);
            });
        },
        createFilter2(queryString) {
            return restaurant => {
                return (
                    restaurant.realName
                        .toLowerCase()
                        .indexOf(queryString.toLowerCase()) === 0
                );
            };
        },
        handleSelect2(item) {
            this.queryBox.belongTo = item.id;
        },
        // 获取销售姓名
        get_sale_name() {
            this.$api.dropdown.users({ userType: 3 }).then(res => {
                this.belongTo = res.userInfoList;
            });
        },
        // 点击客户类型
        typeChange() {
            if (this.saveData.customerType == 5) {
                this.saveData.customerProgress = "8";
            }
        },
        // 点击客户进展
        progressChange(e) {
            if (this.saveData.customerProgress == 8) {
                this.saveData.customerType = "5";
            }
            if (e != 8) {
                this.saveData.payType = "";
                this.saveData.payNum = "";
                this.saveData.invoice = "";
            }
        },
        // 获取导入部门
        get_student_importDepartment() {
            this.$api.user
                .optionsList({ codeType: "student_import_department" })
                .then(res => {
                    this.student_import_department = res.keyValueList;
                });
        },
        // 获取年级
        get_grade() {
            this.gradeCache = JSON.parse(localStorage.getItem("gradeCache"));
            this.subject_Options = JSON.parse(
                localStorage.getItem("studentSubject")
            );
        },

        // 获取沟通结果
        get_result() {
            this.student_result_options = JSON.parse(
                localStorage.getItem("progressResult")
            );
        },

        // 选择沟通结果
        contractResultChange() {
            if (this.saveData.contractResult != "") {
                // this.saveData.contractContent = "";
            }
        },
        // 获取跟进时候的客户进展
        get_track_progress() {
            this.$api.student.studentTrackProgress().then(res => {
                this.student_progress_options2 = res.keyValueList;
            });
        },
        // 报告类型
        get_reportType() {
            this.reportType_options = JSON.parse(
                localStorage.getItem("studentReportType")
            );
        },
        // 报告结果
        get_reportResult() {
            this.reportResult_options = JSON.parse(
                localStorage.getItem("studentReportResult")
            );
        },
        // 获取网推的下拉选项
        get_TG_options() {
            this.student_TGsource_options = JSON.parse(
                localStorage.getItem("studentTGsource")
            );
        },
        // 点击跟进里面报告结果 查看按钮
        handleReportResult() {
            // let params={
            //   phone:this.saveData.phone,
            //   reportType:this.saveData.reportType
            // }
            //  this.$router.push({
            //   path: "/studentInfo/toStudentReportPage",
            //   query: {
            //     phone:this.saveData.phone,
            //   reportType:this.saveData.reportType
            //   }
            // });
            // window.open=("/studentInfo/toStudentReportPage?phone=" +this.saveData.phone+"&reportType="+this.saveData.reportType,'blank')
            var url =
                "/studentInfo/toStudentReportPage?phone=" +
                this.saveData.phone +
                "&reportType=" +
                this.saveData.reportType;
            window.location.href = url;
        },
        studentSubject() {
            this.studentSubject = JSON.parse(
                localStorage.getItem("studentSubject")
            );
        },
        // 关闭索要弹窗
        colsePop(val) {
            this.askingforShow = false;
        },
        openAsking() {
            this.askingforShow = true;
        },
        // 索要资源
        submitAsking(val) {
            this.askingMessage = val;
            this.askingloading = true;
            this.$api.student.AskingFor({ phone: val }).then(res => {
                if (res.result == 1) {
                    this.$message({
                        message: res.msg,
                        type: "success"
                    });
                    this.askingloading = false;
                    this.askingforShow = false;
                    this.isLoadingSuccess = true;
                } else {
                    this.$message({
                        message: res.msg,
                        type: "error"
                    });
                    this.askingloading = false;
                    this.isLoadingSuccess = false;
                }
            });
        },
        // 查询角色信息
        queryUserRole() {
            this.$api.role.queryUserRole().then(res => {
                if (res.result == 1) {
                    this.roleId = res.userInfo.roleId;
                    if (
                        this.roleId == this.roleId1 ||
                        this.roleId == this.roleId2 ||
                        this.roleId == this.roleId3 ||
                        this.roleId == this.roleId4 ||
                        this.roleId == this.roleId5
                    ) {
                        this.columns.map(item => {
                            if (item.id) {
                                item.customerSource = "customerSource";
                            }
                        });
                        this.hideSome = true;
                    }
                }
            });
        },
        closeTrackingPop() {
            this.saveData.sparePhoneAdress = "";
            this.isHaveBehavior2 = false;
            this.isHaveBehavior = false;
            this.trackingLock(this.trackingLockPhone, 2);
        },
        // 打开学习行为
        studyBehavior: function() {
            this.studyLogData2 = [];
            this.drawer = true;
            this.studyAction = false;
            this.isLaodingActionLoadDone = true;
            this.studyLogData = [];
            this.pageRequest2.pageNum = 1;
            this.loading30dayState = true;
            this.loading2dayState = false;
            this.toNext = false;
            this.loading2dayStateTOnext = false;
            this.studentActionLoad();
        },
        studyBehavior2: function() {
            this.studyLogData2 = [];
            this.drawer = true;
            this.studyAction = true;
            this.isLaodingActionLoadDone = false;
            this.pageRequest2.pageNum = 1;
            this.studyLogData = [];
            this.loading30dayState = false;
            this.loading2dayState = true;
            this.loading2dayStateTOnext = false;
            this.toNext = true;
            this.studentActionLoad2();
        },
        // 加载学生学习行为
        studentActionLoad(params, handleFollow) {
            this.studyAction = false;
            function timestampToTime(timestamp) {
                let date = new Date(timestamp);
                var Y = date.getFullYear() + "";
                var M =
                    (date.getMonth() + 1 < 10
                        ? "0" + (date.getMonth() + 1)
                        : date.getMonth() + 1) + "";
                return Y + M;
            }
            // 当月
            let month = timestampToTime(new Date().getTime());
            // 上个月
            // let month2 = getPreMonth(month);
            // 有数据的
            let haveDataPhone = "13200015896";
            let phone = this.saveData.phone;

            this.$api.student
                .queryStudyLog({ phone: phone, month: month })
                .then(res => {
                    let data = JSON.parse(res.msg);

                    if (res.result == 2) {
                        if (!handleFollow) {
                            this.$message({
                                message: res.msg,
                                type: "warning"
                            });
                        }
                        this.drawerLoading = false;
                    } else {
                        let data = JSON.parse(res.msg);
                        if (data.status == 202) {
                            if (!handleFollow) {
                                this.$message({
                                    message: data.message,
                                    type: "warning"
                                });
                            }
                            this.isHaveBehavior = false;
                            this.drawerLoading = false;
                            this.noMore = true;
                            this.studyAction = false;
                        } else {
                            this.studyLogData = data.data;
                            this.isHaveBehavior = true;

                            this.studyLogData.forEach(item => {
                                if (item.activityTypeLabel == "测评") {
                                    item.studyLogType = "参加";
                                }
                                if (item.activityTypeLabel == "听课") {
                                    item.studyLogType = "听";
                                }
                                if (item.activityTypeLabel == "考试") {
                                    item.studyLogType = "参加";
                                }
                            });

                            this.drawerLoading = false;
                            this.noMore = true;
                        }
                    }
                });
        },
        loading2dayData() {
            this.loading2dayStateTOnext = true;
            this.toNext = false;
            this.pageRequest3.pageNum = 1;
            this.loading2dayDataToNext();
        },
        loading2dayDataToNext(params) {
            this.pageRequest3.pageNum++;
            let phone = this.saveData.phone;
            this.drawerLoading = true;
            this.$api.student
                .queryActionLog({
                    phone: phone,
                    pageSize: this.pageRequest2.pageSize,
                    querytwoDaysAgoInfo: 2,
                    pageNum:
                        params == "undefined"
                            ? this.pageRequest3.pageNum
                            : params,
                    queryType: 1
                })
                .then(res => {
                    if (res.result == 1) {
                        this.$message({
                            message: res.msg,
                            type: "error"
                        });
                    } else {
                        if (res.listData.length == 0) {
                            if (params > 1) {
                                this.$message({
                                    message: "没有更多了！",
                                    type: "warning"
                                });
                                this.isLaodingActionLoadDone = true;
                                this.loading2dayStateTOnext = false;
                            }
                            if (!params) {
                                this.isLaodingActionLoadDone = true;
                                this.$message({
                                    message: "两天前行为记录为空！",
                                    type: "warning"
                                });
                                this.toNext = false;
                                this.loading2dayStateTOnext = false;
                                this.loading2dayState = false;
                            }
                            if (params == "1") {
                                this.isHaveBehavior2 = true;
                            }
                        } else {
                            res.listData.forEach(item => {
                                // if(item.doSomething.match(/\【(.+?)\】/g)){
                                //   item.doSomethingStr=item.doSomething.match(/\【(.+?)\】/g).pop().replace(/\【|】/g, '' )
                                //   var newarr=item.doSomething.match(/\【(.+?)\】/g).concat();
                                //   newarr.pop();
                                //   item.doSomething=newarr.toString()
                                //   console.log(item.doSomethingStr)
                                // }else{
                                let index =
                                    item.doSomething.lastIndexOf("http") ||
                                    item.doSomething.lastIndexOf("https");
                                if (index > -1) {
                                    item.doSomethingStr = item.doSomething.substring(
                                        index,
                                        item.doSomething.length
                                    );
                                    item.doSomething = item.doSomething.substring(
                                        0,
                                        index
                                    );
                                }

                                // }
                            });
                            this.isHaveBehavior2 = false;
                            this.loading2dayState = false;
                            this.studyLogData2 = this.studyLogData2.concat(
                                res.listData
                            );
                        }
                    }
                    this.drawerLoading = false;
                });
        },
        loading30dayData() {
            this.drawerLoading = true;
            function timestampToTime(timestamp) {
                let date = new Date(timestamp);
                var Y = date.getFullYear() + "-";
                var M =
                    (date.getMonth() + 1 < 10
                        ? "0" + (date.getMonth() + 1)
                        : date.getMonth() + 1) + "-";
                var D = date.getDate() + " ";
                var h = date.getHours() + ":";
                var m = date.getMinutes() + ":";
                var s = date.getSeconds();
                return Y + M;
            }
            // 当月
            let month = timestampToTime(new Date().getTime());
            // 上个月
            let month2 = getPreMonth(month);
            var month3 = /\d{4}-\d{1,2}/g.exec(month2)[0].replace(/\-/g, "");
            // 有数据的
            let haveDataPhone = "13200015896";
            let phone = this.saveData.phone;
            this.$api.student
                .queryStudyLog({ phone: phone, month: month3 })
                .then(res => {
                    let data = JSON.parse(res.msg);
                    if (res.result == 2) {
                        this.$message({
                            message: res.msg,
                            type: "warning"
                        });
                        this.drawerLoading = false;
                    } else {
                        let data = JSON.parse(res.msg);
                        if (data.status == 202) {
                            this.$message({
                                message: data.message,
                                type: "warning"
                            });
                            this.drawerLoading = false;
                            this.noMore = true;
                            this.studyAction = false;
                            this.isHaveBehavior = false;
                        } else {
                            this.studyLogData = this.studyLogData.concat(
                                data.data
                            );
                            this.isHaveBehavior = true;
                            if (data.data.length == 0) {
                                this.$message({
                                    message: "没有更多了！",
                                    type: "warning"
                                });
                                this.drawerLoading = false;
                            } else {
                                this.studyLogData.forEach(item => {
                                    if (item.activityTypeLabel == "测评") {
                                        item.studyLogType = "参加";
                                    }
                                    if (item.activityTypeLabel == "听课") {
                                        item.studyLogType = "听";
                                    }
                                    if (item.activityTypeLabel == "考试") {
                                        item.studyLogType = "参加";
                                    }
                                });
                                this.studyLogData = this.studyLogData.concat(
                                    data.data
                                );
                                this.drawerLoading = false;
                                this.noMore = true;
                                this.loading30dayState = false;
                            }
                        }
                    }
                });
        },
        // 查询行为
        studentActionLoad2(params, handleFollow) {
            this.isHaveBehavior2 = false;
            this.isLaodingActionLoadDone = false;
            this.drawerLoading = true;
            // 有数据的
            if (!params) {
                this.pageRequest2.pageNum = 1;
            } else {
                this.pageRequest2.pageNum++;
            }
            let haveDataPhone = "13200015896";

            let phone = this.saveData.phone;
            this.$api.student
                .queryActionLog({
                    phone: phone,
                    pageSize: this.pageRequest2.pageSize,
                    querytwoDaysAgoInfo: 1,
                    pageNum: this.pageRequest2.pageNum,
                    queryType: 1
                })
                .then(res => {
                    if (res.result == 1) {
                        this.$message({
                            message: res.msg,
                            type: "error"
                        });
                    } else {
                        if (res.listData) {
                            if (res.listData.length == 0) {
                                // this.loading2dayDataToNext('1')
                                if (params > 0) {
                                    this.$message({
                                        message: "没有更多了！",
                                        type: "warning"
                                    });
                                    this.toNext = false;
                                    this.isLaodingActionLoadDone = true;
                                }
                                if (!params) {
                                    this.isLaodingActionLoadDone = true;
                                    if (!handleFollow) {
                                        // this.$message({
                                        //   message: "两天内行为记录为空！",
                                        //   type: "warning"
                                        // });
                                        this.loading2dayData();
                                    }
                                    this.toNext = false;
                                    this.isHaveBehavior2 = true;
                                }
                            } else {
                                this.toNext = true;
                                this.loading2dayState = false;
                                this.studyLogData2 = this.studyLogData2.concat(
                                    res.listData
                                );
                                res.listData.forEach(item => {
                                    let index =
                                        item.doSomething.lastIndexOf("http") ||
                                        item.doSomething.lastIndexOf("https");
                                    if (index > -1) {
                                        item.doSomethingStr = item.doSomething.substring(
                                            index,
                                            item.doSomething.length
                                        );
                                        item.doSomething = item.doSomething.substring(
                                            0,
                                            index
                                        );
                                    }
                                });
                            }
                        } else {
                            this.$message({
                                message: "没有更多了！",
                                type: "warning"
                            });

                            this.toNext = false;
                            this.loading2dayState = true;
                            // this.loading2dayStateTOnext=true
                        }
                    }
                    this.drawerLoading = false;
                });
        },
        // 查询行为控制跟进按钮
        studentActionLoad3(params, handleFollow) {
            this.isHaveBehavior2 = false;
            // 有数据的
            if (!params) {
                this.pageRequest2.pageNum = 1;
            } else {
                this.pageRequest2.pageNum++;
            }
            let haveDataPhone = "13200015896";

            let phone = this.saveData.phone;
            this.$api.student
                .queryActionLog({
                    phone: phone,
                    pageSize: this.pageRequest2.pageSize,
                    querytwoDaysAgoInfo: 1,
                    pageNum: this.pageRequest2.pageNum,
                    queryType: 1
                })
                .then(res => {
                    if (res.result == 1) {
                        this.$message({
                            message: res.msg,
                            type: "error"
                        });
                    } else {
                        if (res.listData) {
                            if (res.listData.length == 0) {
                                this.loading2dayDataToNext2("1");
                                if (params > 0) {
                                    this.$message({
                                        message: "没有更多了！",
                                        type: "warning"
                                    });
                                    this.isLaodingActionLoadDone = true;
                                }
                                if (!params) {
                                    this.isLaodingActionLoadDone = true;
                                    if (!handleFollow) {
                                        this.$message({
                                            message: "两天内行为记录为空！",
                                            type: "warning"
                                        });
                                    }

                                    this.isHaveBehavior2 = true;
                                }
                            } else {
                                this.studyLogData2 = this.studyLogData2.concat(
                                    res.listData
                                );
                            }
                        } else {
                            this.$message({
                                message: "没有更多了！",
                                type: "warning"
                            });
                        }
                    }
                    this.drawerLoading = false;
                });
        },
        loading2dayDataToNext2(params) {
            this.pageRequest3.pageNum++;
            let phone = this.saveData.phone;

            this.$api.student
                .queryActionLog({
                    phone: phone,
                    pageSize: this.pageRequest2.pageSize,
                    querytwoDaysAgoInfo: 2,
                    pageNum:
                        params == "undefined"
                            ? this.pageRequest3.pageNum
                            : params,
                    queryType: 1
                })
                .then(res => {
                    if (res.result == 1) {
                        this.$message({
                            message: res.msg,
                            type: "error"
                        });
                    } else {
                        if (res.listData.length == 0) {
                            if (params > 1) {
                                this.$message({
                                    message: "没有更多了！",
                                    type: "warning"
                                });
                                this.isLaodingActionLoadDone = true;
                            }
                            if (!params) {
                                this.isLaodingActionLoadDone = true;
                                this.$message({
                                    message: "两天前行为记录为空！",
                                    type: "warning"
                                });
                                this.toNext = true;
                                this.loading2dayStateTOnext = false;
                            }
                            if (params == "1") {
                                this.isHaveBehavior2 = true;
                            }
                        } else {
                            this.isHaveBehavior2 = false;
                            this.studyLogData2 = this.studyLogData2.concat(
                                res.listData
                            );
                        }
                    }
                    this.drawerLoading = false;
                });
        },
        drawerClose() {
            this.studyLogData2 = [];
            this.drawer = false;
        },
        // 查询订单
        queryOrderBtn(params) {
            this.$api.student
                .queryStudentPayOrderList({
                    phone: params == "" ? this.trackingLockPhone : params
                })
                .then(res => {
                    if (res.result == 2) {
                        this.$message({ message: res.msg, type: "error" });
                    } else {
                        res.data.orderInfo = res.data.orderInfo.map(item => {
                            // 转化分主题

                            if (item.indexOf("http") || item.indexOf("https")) {
                                let index =
                                    item.indexOf("http") ||
                                    item.indexOf("https");
                                if (index > -1) {
                                    return {
                                        order: item.substring(0, index),
                                        orderLink: item.substring(
                                            index,
                                            item.length
                                        )
                                    };
                                } else {
                                    item.orderLink = null;
                                    return {
                                        order: item,
                                        orderLink: null
                                    };
                                }
                            }
                        });
                        let arry = [];
                        arry = res.data.orderInfo.forEach(item => {
                            if (item.orderLink.indexOf("】")) {
                                let index = item.orderLink.indexOf("】");
                                if (index > -1) {
                                    return (item.orderLink = item.orderLink.substring(
                                        0,
                                        index
                                    ));
                                }
                            }
                        });

                        this.orderList = res.data.orderInfo;
                        this.orderList.length > 0
                            ? (this.haveOrder = true)
                            : (this.haveOrder = false);
                    }
                });
        },
        delArrVal(arr, val) {
            //查找数组中的某个值并全部删除    第一个参数是查找的数组 第二个参数是删除的值
            for (let i = 0; i < arr.length; i++) {
                if (arr[i] == val) {
                    arr.splice(i, 1);
                    i--;
                }
            }
            return arr;
        },
        clickQueryOrderBtn() {
            this.allOrderShow = true;
        },
        // 资源查询二级
        dataFromGroupKeyChange(params) {
            this.queryBox.dataFrom = "";
            if (params != "") {
                this.$api.dropdown
                    .queryStudentDataFromByGroupId({
                        id: params
                    })
                    .then(res => {
                        if (res.result == 2) {
                            this.$message({ message: res.msg, type: "error" });
                        } else {
                            this.resourcesSon_Options = res.data;
                        }
                    });
            }
        }
    },
    beforeMount: function() {
        this.$api.dropdown.studentDataFromGroup().then(res => {
            if (res.result == 1) {
                this.resources_Options = res.keyValueList;
                let arr = res.keyValueList;
                this.resources_Options2 = arr.map(item => {
                    item.codeValue = item.value;
                    item.codeKey = item.key;
                    return item;
                });
            }
        });
    },
    computed: {
        // noMore () {
        //     return !this.drawerLoading
        // },
        disabled() {
            return !this.drawerLoading || this.noMore;
        }
    },
    watch: {
        // student(oldID,newId) {
        //   this.student = newId;
        //   console.log("watch"+newId)
        // },
    },
    updated() {
        // this.findPage(null)
    },
    mounted() {
        this.findPage(null);
        this.get_student_data_from();
        this.get_student_progress();
        this.get_student_type();
        this.get_student_data_from_type();
        this.get_oemType();
        // this.wac();
        this.get_contractType();
        this.get_sale_name();
        this.get_dataTime();
        this.get_tqToken();
        this.get_student_importDepartment();
        this.get_studentContractType();
        this.get_grade_cache();
        this.get_grade();
        this.get_track_progress();
        this.get_student_track_type();
        this.get_reportType();
        this.get_reportResult();
        this.studentSubject();
        this.get_TG_options();
        this.queryUserRole();
        let _this = this; // 声明一个变量指向Vue实例this，保证作用域一致
        this.timer = setInterval(() => {
            _this.date = new Date(); // 修改数据date
        }, 1000);
    },
    destroyed: function() {
        this.demo.destroy();
    },
    beforeDestroy() {
        if (this.timer) {
            clearInterval(this.timer); // 在Vue实例销毁前，清除我们的定时器
        }
    }
};
</script>
<style >
@import url("../../assets/queryBox.css");
</style>
<style lang='scss' scoped>
.orderListPop {
    ul {
        li {
            list-style: none;
            line-height: 20px;
        }
    }
}
.reportBtn {
    color: #fff;
    background-color: #1a7284;
    border-color: #1a7284;
    display: inline-block;
    padding: 3px 10px;
    text-decoration: none;
    border-radius: 2px;
    margin-left: 22px;
    font-size: 12px;
}
.query-box {
    .el-row {
        .el-col i {
            font-style: normal;
            text-align: right;
            float: left;
            font-size: 14px;
            color: #606266;
            line-height: 40px;
            padding: 0 0 0 0;
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
        }
    }
}
.query-box .slect-title,
.query-box .city-title {
    font-weight: bold !important;
}
.checked-person {
    display: block;
    float: left;
    margin-top: -10%;
    margin-left: 35%;
}
.second-contain-box {
    width: 95%;
    margin: 0 auto;
    .el-col {
        text-align: left;
        margin: 4px 0;
    }
    .el-row {
        margin: 0 0 !important;
    }
    .el-col i {
        font-style: normal;
        display: inline-block;
        margin-top: 10%;
    }
}
.inputbox {
    display: flex;
    flex-direction: row;
    span {
        display: block;
        width: 13%;
    }
    .el-input {
        width: 50%;
    }
    .el-textarea {
        float: left;
        margin-left: -4%;
    }
}
</style>
<style lang='scss'>
.myStudent {
    .el-drawer__body {
        overflow: scroll;
    }
    .studentDrawer {
        .list {
            li {
                list-style: none;
                margin: 20px 0;
                // text-align: left;
            }
        }
    }
}

.myStudent .el-form-item {
    margin-bottom: 10px;
}
.batchdistribution-pop {
    .el-dialog__header {
        text-align: left;
        margin-left: 10%;
        font-weight: bold;
    }
}
.red {
    color: red;
}
.query-boxstudent .el-input-group__prepend {
    font-weight: bold !important;
}
.stu-pop .el-select {
    width: 100%;
}
</style>